package hu.u_szeged.inf.ovrt.filelister.core.container;

import hu.u_szeged.inf.ovrt.filelister.core.workflow.Workflow;

import org.apache.log4j.xml.DOMConfigurator;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Application container implementation.
 */
public final class SimpleApplicationContainer implements ApplicationContainer {
    private static final ApplicationContainer INSTANCE = new SimpleApplicationContainer();
    private final ApplicationContext context;
    private final Workflow workflow;

    private SimpleApplicationContainer() {
        DOMConfigurator.configure("conf/log4j.xml");
        context = new ClassPathXmlApplicationContext("classpath*:appconfig.xml");
        workflow = context.getBean("workflow", Workflow.class);
    }

    public static ApplicationContainer getInstance() {
        return INSTANCE;
    }

    @Override
    public void start() {
        workflow.run();
    }
}
